#pragma once
#include "ZuiLib.h"
#include "LRefObject.h"

namespace ZuiLib {

class LRichText :public LRefObject<ZRichText>
{
public:
	int getTextColor(LuaFuncState& L)
	{
		return L.lreturn(pThis->GetTextColor());
	}

	int setTextColor(LuaFuncState& L)
	{
		pThis->SetTextColor(toColor(L.arg(0)));
		return 0;
	}

	int getFontName(LuaFuncState& L)
	{
		return L.lreturn(pThis->GetFontName());
	}

	int setFontName(LuaFuncState& L)
	{
		pThis->SetFontName(L.arg(0).toString());
		return 0;
	}

	int getTextPadding(LuaFuncState& L)
	{
		return L.lreturn(toLua(&L, pThis->GetTextPadding()));
	}

	int setTextPadding(LuaFuncState& L)
	{
		pThis->SetTextPadding(toRect(L.arg(0)));
		return 0;
	}

	int clear(LuaFuncState& L)
	{
		pThis->Clear();
		return 0;
	}

	int appendText(LuaFuncState& L)
	{
		pThis->AppendText(L.arg(0).toString());
		return 0;
	}

	int appendLink(LuaFuncState& L)
	{
		pThis->AppendLink(L.arg(0).toString());
		return 0;
	}

	int appendContent(LuaFuncState& L)
	{
		pThis->AppendContent(L.arg(0).toString());
		return 0;
	}

	int setContent(LuaFuncState& L)
	{
		pThis->SetContent(L.arg(0).toString());
		return 0;
	}

	int getContentSize(LuaFuncState& L)
	{
		return L.lreturn(toLua(&L,pThis->ContentSize(L.arg(0).toString(),L.arg(1).toInt(),pThis->GetFont())));
	}

	int getMaxRowSize(LuaFuncState& L)
	{
		return L.lreturn(toLua(&L,pThis->GetMaxRowSize()));
	}

	int getTextLength(LuaFuncState& L)
	{
		return L.lreturn(pThis->GetTextLength());
	}

	int setTextWidth(LuaFuncState& L)
	{
		pThis->SetTextWidth(L.arg(0).toInt());
		return 0;
	}

	int setSel(LuaFuncState& L)
	{
		pThis->SetSel(L.arg(0).toInt(), L.arg(1).toInt());
		return 0;
	}


	BEGIN_MAP_FUNC(LRichText)
	DECLARE_FUNC(getTextColor),
	DECLARE_FUNC(setTextColor),
	DECLARE_FUNC(getFontName),
	DECLARE_FUNC(setFontName),
	DECLARE_FUNC(getTextPadding),
	DECLARE_FUNC(setTextPadding),
	DECLARE_FUNC(clear),
	DECLARE_FUNC(appendText),
	DECLARE_FUNC(appendLink),
	DECLARE_FUNC(appendContent),
	DECLARE_FUNC(setContent),
	DECLARE_FUNC(getContentSize),
	DECLARE_FUNC(getMaxRowSize),
	DECLARE_FUNC(getTextLength),
	DECLARE_FUNC(setTextWidth),
	DECLARE_FUNC(setSel),
	END_MAP_FUNC
};

}//namespace
